/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Practica4.Practica;

import Practica4.sort.IntegerArray;
import java.util.Random;

/**
 *
 * @author miguel
 */
public class MyIntegerArray implements IntegerArray{

    @Override
    public int[] zigZag(int n, int start) {
        int[] array = new int[n];
        int i = start;
        int j = start-1;
        for(int k=0;k<n;k++){
            if(k%2==0){
                array[k] = i++;
            }else{
                array[k] = j--;
            }
        }
        return array;
    }

    @Override
    public int[] random(int n, int low, int high) {
        int[] array = new int[n];
        Random r = new Random();
        for(int i=0;i<n;i++){
            array[i] = low+r.nextInt(high-low);
        }
        return array;
    }

    @Override
    public void inverse(int[] a) {
        int n = a.length-1;
        int[] b = new int[n];
        for(int i=0;i<n;i++){
            b[i] = a[n-i];
        }
        a = b;
    }
    
}
